#!/usr/bin/python

###############################
## A base function for plots ##
###############################

#######################################################      
## Set PyRoot Environment and PlotConfig Path first ###
#######################################################
import sys
ROOTSYS = '/afs/atlas.umich.edu/opt/root/lib'
sys.path.append(ROOTSYS)
PlotConfig='../'
PlotConfig2='.'
sys.path.append(PlotConfig)
sys.path.append(PlotConfig2)

#####################
## Import Module  ###
#####################
import array
import os
import glob
from math import sqrt,fabs,sin
from ROOT import TFile,TTree,TChain,TBranch,TH1,TH1F,TList
from ROOT import TLorentzVector
from ROOT import THStack,TCanvas,TLegend,TColor,TPaveText
from ROOT import gStyle,gDirectory

####################
## Import Template #
####################
from plot_template_2D import plot_template_2D

###############
## Plotting ###
###############
RatioSize=0.2
RatioErr=-1
RatioMin,RatioMax=0.5,1.5
RatioAdj=-1

ShowMCErr=1
MCErree=0.03157
MCErrmm=0.01276
MCErrll=0.01584

plot_config='plot_configure.cutflow'

#ATLAS='ATLAS For Approval'
ATLAS=''
#ATLAS=''
figFormat='all'

histoDir='NOM'

yscale=2


####### MET
Xmin, Xmax=0, 300
RatioMin,RatioMax=0.5,1.5
Rebin=5
Events=str('Events / %dGeV' % Rebin)
hname=histoDir+'_ee_Zmass_MET_Et_Pt2l'
hxt='E_{T}^{miss},ee [GeV]'
MCErr=MCErree
plot_template_2D(histodir=histoDir,hname=hname,configfile=plot_config)
hname=histoDir+'_em_Zmass_MET_Et_Pt2l'
hxt='E_{T}^{miss},em [GeV]'
MCErr=MCErree
plot_template_2D(histodir=histoDir,hname=hname,configfile=plot_config)
hname=histoDir+'_mm_Zmass_MET_Et_Pt2l'
hxt='E_{T}^{miss},#mu#mu [GeV]'
MCErr=MCErrmm
plot_template_2D(histodir=histoDir,hname=hname,configfile=plot_config)
hname=histoDir+'_incl_Zmass_MET_Et_Pt2l'
hxt='E_{T}^{miss} [GeV]'
MCErr=MCErrll
#plot_template_2D(histodir=histoDir,hname=hname,configfile=plot_config)


hname=histoDir+'_ee_Zmass_MET_STVF_Et_Pt2l'
hxt='E_{T}^{miss},ee [GeV]'
MCErr=MCErree
plot_template_2D(histodir=histoDir,hname=hname,configfile=plot_config)
hname=histoDir+'_em_Zmass_MET_STVF_Et_Pt2l'
hxt='E_{T}^{miss},em [GeV]'
MCErr=MCErree
plot_template_2D(histodir=histoDir,hname=hname,configfile=plot_config)
hname=histoDir+'_mm_Zmass_MET_STVF_Et_Pt2l'
hxt='E_{T}^{miss},#mu#mu [GeV]'
MCErr=MCErrmm
plot_template_2D(histodir=histoDir,hname=hname,configfile=plot_config)
hname=histoDir+'_incl_Zmass_MET_STVF_Et_Pt2l'
hxt='E_{T}^{miss} [GeV]'
MCErr=MCErrll
#plot_template_2D(histodir=histoDir,hname=hname,configfile=plot_config)


dir='2D_MET_'+histoDir
if not os.path.isdir(dir): os.mkdir(dir)
cmd='mv *.pdf *.png *.eps *.root '+dir
os.system(cmd)
